package com.itheima.tomcat;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 薛虎
 * @date 2021/1/22 9:33
 * 所有请求被拦截后,请求会交给DispatcherServlet
 */
public class DispatcherServlet extends HttpServlet {

    /**
     * DispatcherServlet每当一个请求过来,它都会开启一个新的线程
     * 同时调用执行service方法
     *
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //httpServerHandler真正处理远程调用请求
        new HttpServerHandler().handle(req, resp);
    }
}
